/*
 * Description: performance registry controll utils
 */
#ifndef REGISTRY_UTILS_EX_H
#define REGISTRY_UTILS_EX_H
#include <vector>
#include <string>
#include "Windows.h"

namespace PERF {

#ifdef UNICODE
using TString = std::wstring;
#else
using TString = std::string;
#endif

class RegistryUtilsEx {
public:
    RegistryUtilsEx(HKEY hRoot, const TString& targetKey) noexcept;
    ~RegistryUtilsEx() noexcept;

    TString ToErrorString(DWORD err);

    LONG RegSetDword(const TString& field, const DWORD data);
    LONG RegGetDword(const TString& field, DWORD& data);
    LONG RegSetString(const TString& field, const TString& data);
    LONG RegGetString(const TString& field, TString& data);
    // This function has not been used. Before invoking this function, verify its correctness
    LONG RegGetQDword(const TString& field, ULONGLONG& data);
    LONG RegTraverseHKey(std::vector<std::pair<TString, DWORD>>& result);

private:
    HKEY rootKey_;
    HKEY subKey_;
};

}  // namespace PERF

#endif